class AsteroidWithSize: public AsteroidPelem
{
public:
  float D, sigmaD;
  float pV, sigmapV;
  char   hasWiseObs;
  double mass;
  double volume;
  double density;

  float eta;
  float sigmaEta;

  float pIR;
  float sigmapIR;

  float pW1;
  float sigmapW1;
  float pW2;
  float sigmapW2;

  int    nW1, nW2, nW3, nW4; // number of WISE FILTER DETECTION
  int    nIR1, nIR2, nIR3, nIR4; // number of IRAS FILTER DETECTION
 
  AsteroidWithSize():AsteroidPelem()
  {
    sigmapW2=pW2=sigmapW1=pW1=sigmapIR=pIR=
      eta=sigmaEta=pIR=
      sigmapIR=hasWiseObs=D=sigmaD=pV=sigmapV=0;
    nW1=nW2=nW3=nW4=nIR1=nIR2=nIR3=nIR4=0;
  };

  void reset() // reset everything 
  {
    AsteroidPelem::reset();
    sigmapW2=pW2=sigmapW1=pW1=sigmapIR=pIR=
      eta=sigmaEta=pIR=
      sigmapIR=hasWiseObs=D=sigmaD=pV=sigmapV=0;
    nW1=nW2=nW3=nW4=nIR1=nIR2=nIR3=nIR4=0;
  }
  
  void resetD() // reset D, pV and related fields but not everything 
  {
    sigmapW2=pW2=sigmapW1=pW1=sigmapIR=pIR=
      eta=sigmaEta=pIR=
      sigmapIR=hasWiseObs=D=sigmaD=pV=sigmapV=0;
    nW1=nW2=nW3=nW4=nIR1=nIR2=nIR3=nIR4=0;
  }

  AsteroidWithSize(string line)
  {
    WISERenumberedString2Asteroid(line);
  };

  void WISERenumberedString2Asteroid(string line)
  {
    sscanf(&line.at(0), "%ld %20s %f %f %f %f",&Number,Designation,&D,&sigmaD,&pV,&sigmapV);
  };

  void Masiero11String2Asteroid(string line)
  {
    reset();
    memset(pack,0,10);
    line2pack(line);
    sscanf(&line.at(0), "%*s %f %f %f %f %f %f %f %f %f %f %d %d %d %d", &H, &G,
	   &D,&sigmaD,&pV,&sigmapV,&eta,&sigmaEta,&pIR,&sigmapIR,&nW1,&nW2,&nW3,&nW4);
    MPC2DesignationCompact();	    
  };

  void Masiero12String2Asteroid(string line)
  {
    reset();
    memset(pack,0,10);
    line2pack(line);
    sscanf(&line.at(0), "%*s %f %f %f %f %f %f %d %d %d", &H, &G,
	   &D,&sigmaD,&pV,&sigmapV,&nW1,&nW2,&nW3);
    MPC2DesignationCompact();	    
  };

  void Masiero14String2Asteroid(string line)
  {
    reset();
    memset(pack,0,10);
    line2pack(line);
    sscanf(&line.at(0), "%*s %f %f %f %f %f %f",&D,&sigmaD,&eta,&sigmaEta,&pV,&sigmapV);
    /*    
    sscanf(&line.at(0), "%s %lf %lf",pack,&D,&sigmaD);
    pV=atof(line.substr(29,4).c_str());
    sigmapV=atof(line.substr(34,4).c_str());
    */
    MPC2DesignationCompact();	    
  };

  void Nugent15String2Asteroid(string line)
  {
    reset();
    memset(pack,0,10);
    memcpy(pack, &line.at(11),7);
    Number=atol(line.substr(0,5).c_str());  
    D=atof(line.substr(31,6).c_str());
    sigmaD=atof(line.substr(38,5).c_str());
    pV=atof(line.substr(44,4).c_str());
    sigmapV=atof(line.substr(49,4).c_str());
    eta=atof(line.substr(54,4).c_str());
    sigmaEta=atof(line.substr(59,4).c_str());
    nW1=atol(line.substr(69,2).c_str());
    nW2=atol(line.substr(72,2).c_str());
    MPC2DesignationCompact();	    
  };

  void Nugent16MBAString2Asteroid(string line)
  {
    reset();
    memset(pack,0,10);
    memcpy(pack, &line.at(11),7);
    Number=atol(line.substr(0,10).c_str());  
    D=atof(line.substr(31,6).c_str());
    sigmaD=atof(line.substr(38,5).c_str());
    pV=atof(line.substr(44,4).c_str());
    sigmapV=atof(line.substr(49,4).c_str());
    eta=atof(line.substr(54,4).c_str());
    sigmaEta=atof(line.substr(59,4).c_str());
    nW1=atol(line.substr(79,2).c_str());
    nW2=atol(line.substr(82,2).c_str());
    MPC2DesignationCompact();	    
  };

  void Nugent16NEAString2Asteroid(string line)
  {
    reset();
    memset(pack,0,10);
    memcpy(pack, &line.at(11),7);
    Number=atol(line.substr(0,10).c_str());  
    D=atof(line.substr(30,4).c_str());
    sigmaD=atof(line.substr(35,4).c_str());
    pV=atof(line.substr(40,4).c_str());
    sigmapV=atof(line.substr(45,4).c_str());
    eta=atof(line.substr(50,4).c_str());
    sigmaEta=atof(line.substr(55,4).c_str());
    nW1=atol(line.substr(75,2).c_str());
    nW2=atol(line.substr(79,2).c_str());
    MPC2DesignationCompact();	    
  };

  void simpsString2Asteroid(string line)
  {
    reset();
    memset(pack,0,10);
    memset(Designation,0,20);
    Number=atol(line.substr(0,5).c_str());

    char *read = &line.at(6);
    char *write = Designation;

    // compact the designation by removing spaces or the underscore
    // remove spaces
    int i=0;
    do {
      if ((*read != ' ') && (*read != '_')) 
	*write++ = *read;
    } while ((*read++) && (i++<16)); // until a NULL is found

    D=atof(line.substr(43,6).c_str());
    sigmaD=atof(line.substr(52,4).c_str());
    pV=atof(line.substr(29,6).c_str());
    sigmapV=atof(line.substr(36,5).c_str());
    number2pack();
  };

  void akariString2Asteroid(string line)
  {
    reset();
    memset(pack,0,10);
    memset(Designation,0,20);
    
    Number=atol(line.substr(0,6).c_str());

    char *read = &line.at(26);
    char *write = Designation;

    // compact the designation by removing spaces or the underscore
    // remove spaces
    int i=0;
    do {
      if ((*read != ' ') && (*read != '_')) 
	*write++ = *read;
    } while ((*read++) && (i++ < 10)); // until a NULL is found

    D=atof(line.substr(53,6).c_str());
    sigmaD=atof(line.substr(60,5).c_str());
    pV=atof(line.substr(66,5).c_str());
    sigmapV=atof(line.substr(72,5).c_str());
    designation2pack();	    
  };

  void victorString2Asteroid(string line)
  {
    reset();
    memset(pack,0,10);
    memset(Designation,0,20);
    line2pack(line);
    
    sscanf(&line.at(0),"%*s %f %f %f %f %f %f", &H,&G,&D,&sigmaD,&pV,&sigmapV);

    MPC2Number();
  };

  void victorMarsCrossersString2Asteroid(string line)
  {
    reset();
    memset(pack,0,10);
    memset(Designation,0,20);
    line2pack(line);
    
    sscanf(&line.at(0),"%*s %f %f %f %f %f %f %f %f %*f %*f %*f %*f %d %d %d %d",
	   &H,&G,&D,&sigmaD,&pV,&sigmapV,&eta,&sigmaEta,
	   &nW1, &nW2, &nW3, &nW4);

    MPC2DesignationCompact();
  };

  void EARNString2Asteroid(string line)
  {
    char dummyChar[10];

    reset();
    memset(pack,0,10);
    
    memset(dummyChar,0,10);
    strncpy(dummyChar,&line.at(40),8);
    Number=atol(dummyChar);  

    if (Number<=0)
      {
	char *read = &line.at(48);
	char *write = Designation;

	// compact the designation by removing spaces or the underscore
	// remove spaces
	int i=0;
	do {
	  if ((*read != ' ') && (*read != '_')) 
	    *write++ = *read;
	} while ((*read++) && (i++ < 14)); // until a NULL is found
	
	designation2pack();
      } else
        number2pack();

    memset(dummyChar,0,10);
    strncpy(dummyChar,&line.at(92),7);
    pV=atof(dummyChar);
    
    memset(dummyChar,0,10);
    strncpy(dummyChar,&line.at(99),9);
    D=atof(dummyChar);
  };

  void print()
  {
    /*    printf("%06ld %20s %10s %5.2f %5.2f %7.4lf %7.4lf %7.4lf %7.4lf %7.4lf %7.4lf %8.3f %7.f %5.3f %5.3f, %d\n",
	   Number, Designation, pack, H, G, a, e, sini, ap, ep, sinip,
	   D, sigmaD, pV, sigmapV, hasWiseObs);
    */
    printf("%ld %20s %10s %f %f %f %f %f %f %f %f\n", Number, Designation, pack, H, G, D, sigmaD, pV, sigmapV, eta, sigmaEta);
  };
 
  void setpV(double _pV)
  {
    pV=_pV;
  };

  void importWiseData(string wiseData)
  {
  };

  void HD2pV()
  {
    pV=1329.*1329./D/D*pow(10, -H/2.5);
    sigmapV=pV*.3;
  }
};

